<?php
require_once "config.php";
require_once 'class/class.phpmailer.php';
require_once 'extranet_utils.php';
//error_reporting(false);
$memberobj=new Member();
$member_id=$_SESSION['member_id'];
$member_orders=$memberobj->get_member_orders($member_id, 'C');  //complete otrders
$member_orders_incomplete=$memberobj->get_member_orders($member_id, 'X');  //incomplete otrders
$completion_status=array('C'=>'Completed', 'P'=>'Pending', 'A'=>'Active');
//print_r($member_orders);

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Hotels With Offers</title>
<script language="Javascript" type="text/javascript" src="js/jquery-1.4.1.js"></script>
<script language="Javascript" type="text/javascript" src="js/jquery.lwtCountdown-1.0.js"></script>
<script language="Javascript" type="text/javascript" src="js/misc.js"></script>
<script src="SpryAssets/SpryTabbedPanels.js" type="text/javascript"></script>
<link href="css/main.css" rel="stylesheet" type="text/css" />
<link href="SpryAssets/SpryTabbedPanels.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery.validate.js"></script>


</head>

<body>
<div id="wrapper">
    <?php require_once 'top_header.php'; ?>    
<div class="contentPane">
  <div id="sidebar">
    <span class="menu"><img src="images/call.png" alt="Advertise with Hotel with Offers" class="callus"  /></span>
    <div class="joinus">
      <h1>INVITE A FRIEND</h1>
      <h2>Tell a friend and win Rs100.00</h2>
      <div class="joinbtn"><a href="#">LEARN&nbsp;MORE</a></div>
     </div>
    <div class="reserve"><span class="reserveitem">Reserved for :</span> <span class="reserveitem">advertising</span> <span class="reserveitem">latest news</span> <span class="reserveitem">soon ending deals &amp; offers</span></div>
  </div>
  <div class="leftPane">
        <div class="mainMenu"><?php require_once 'main_menu.php'; ?></div>
        <?php require_once 'newsletter_plug.php'; ?>
    <div id="TabbedPanels1" class="TabbedPanels">
   
    <ul class="TabbedPanelsTabGroup">
      <li class="TabbedPanelsTab" tabindex="0">Completed Orders</li>
      <li class="TabbedPanelsTab" tabindex="1">In-Completed Orders</li>
    </ul>
    <div class="TabbedPanelsContentGroup">
        <div class="TabbedPanelsContent">
        <?php if(!empty($member_orders)):?>
        <table class="my_orders">
            <tr>
                <th>Order Number</th>
                <th>Offer Title</th>
                <th>Regular Price</th>
                <th>Offer Price</th>
                <th>Voucher Qty.</th>
                <th>Credits Redeemed</th>                
                <th>Order Date</th>
                <th>Order Status</th>
                <th>Order Total</th>
                <th>&nbsp;</th>
            </tr>
        <?php foreach ($member_orders as $key => $val) :
            $url="ordersummary.php?id=". $val['order_id'];
            if($val['order_status']!='C'){
                //$url="submit_now();";
                $url="buynow.php?offer_prefix=".$val['offer_prefix']."&oid=".$val['order_id'];
            }
            $order_total = floatval($val['discount_amount']*$val['no_of_offer_vouchers'])-floatval(!empty($val['credits_redeemed'])?$val['credits_redeemed']:0);
            if($order_total<0){
                $order_total=0;
            }
            ?>
            <tr>
                <td><a href="<?php echo $url;?>"><?php echo $val['order_number'];?></a></td>
                <td><?php echo $val['offer_title'];?></td>                
                <td><?php echo ($val['regular_amount'])>0?intval($val['regular_amount']):number_format(0.00, 2);?></td>
                <td><?php echo ($val['discount_amount'])>0?intval($val['discount_amount']):number_format(0.00, 2);?></td>
                <td><?php echo $val['no_of_offer_vouchers'];?></td>                
                <td><?php echo ($val['credits_redeemed'])>0?intval($val['credits_redeemed']):number_format(0.00, 2);?></td>
                <td><?php echo $val['creation_date'];?></td>
                <td><?php echo $completion_status[$val['order_status']];?></td>
                <td align="right"><?php echo $order_total==0?number_format($order_total, 2):$order_total;?></td>
                <td><a href="<?php echo $url;?>">View</a></td>
            </tr>
        <?php endforeach;?>
        </table>
        <?php else:?>
        <span>No completed orders found!</span>
        <?php endif; ?>
        </div>
        <div class="TabbedPanelsContent">
        <?php if(!empty($member_orders_incomplete)):?>
        <table class="my_orders">
            <tr>
                <th>Order Number</th>
                <th>Offer Title</th>
                <th>Regular Price</th>
                <th>Offer Price</th>
                <th>Voucher Qty.</th>
                <th>Credits Redeemed</th>                
                <th>Order Date</th>
                <th>Order Status</th>
                <th>Order Total</th>
                <th>&nbsp;</th>
            </tr>
        <?php foreach ($member_orders_incomplete as $key => $val) :
            $url="ordersummary.php?id=". $val['order_id'];
            if($val['order_status']!='C'){
                //$url="submit_now();";
                $url="buynow.php?offer_prefix=".$val['offer_prefix']."&oid=".$val['order_id'];
            }
            $order_total = floatval($val['discount_amount']*$val['no_of_offer_vouchers'])-floatval(!empty($val['credits_redeemed'])?$val['credits_redeemed']:0);
            if($order_total<0){
                $order_total=0;
            }
            ?>
            <tr>
                <td><a href="<?php echo $url;?>"><?php echo $val['order_number'];?></a></td>
                <td><?php echo $val['offer_title'];?></td>                
                <td><?php echo $val['regular_amount']>0?intval($val['regular_amount']):number_format(0.00, 2);?></td>
                <td><?php echo ($val['discount_amount'])>0?intval($val['discount_amount']):number_format(0.00, 2);?></td>
                <td><?php echo $val['no_of_offer_vouchers'];?></td>                
                <td><?php echo ($val['credits_redeemed'])>0?intval($val['credits_redeemed']):number_format(0.00, 2);?></td>
                <td><?php echo $val['creation_date'];?></td>
                <td><?php echo $completion_status[$val['order_status']];?></td>
                <td align="right"><?php echo $order_total==0?number_format($order_total, 2):$order_total;?></td>
                <td><a href="<?php echo $url;?>">Proceed</a></td>
                <!--<td style="border: 1px solid #333;"><a href="<?php echo $url;?>"><?php echo $val['order_number'];?></a></td>
                <td style="border: 1px solid #333;"><?php echo $val['offer_title'];?></td>
                <td style="border: 1px solid #333;"><?php echo $val['offer_start_date'];?></td>
                <td style="border: 1px solid #333;"><?php echo $val['offer_end_date'];?></td>
                <td style="<td style="border: 1px solid #333;"><?php echo $val['creation_date'];?></td>border: 1px solid #333;"><?php echo $val['regular_amount'];?></td>
                <td style="border: 1px solid #333;"><?php echo $val['discount_amount'];?></td>
                <td style="border: 1px solid #333;"><?php echo $val['creation_date'];?></td>
                <td style="border: 1px solid #333;"><?php echo $val['order_status'];?></td>
                <td style="border: 1px solid #333;"><?php echo $val['amount_paid'];?></td>-->
            </tr>
        <?php endforeach;?>
        </table>
        <?php else:?>
        <span>No in-completed orders found!</span>
        <?php endif; ?>
        </div>
    </div>
    </div>
    <div class="clear"></div>
</div>
</div>
<div class="clear"></div>
</div>
<div id="footerWrapper">
<?php require_once 'footer.php'; ?>
</div>
</body>
<script language="javascript" type="text/javascript">
    var TabbedPanels1 = new Spry.Widget.TabbedPanels("TabbedPanels1");
</script>    
<script language="javascript" type="text/javascript">
    
function submit_now(){
    
}
</script>
</html>
